package com.smart.controller;

import com.smart.pojo.LeaveBill;
import com.smart.pojo.OutboundBill;
import com.smart.pojo.ResultBean;
import com.smart.req.LeaveCompleteData;
import com.smart.req.OutboundCompleteData;
import com.smart.service.LeaveProcessService;
import com.smart.service.OutboundProcessService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("outboundProcess")
public class OutboundProcessController {
    @Autowired
    private OutboundProcessService outboundProcessService;

    /**
     * 开启请假流程实例
     */
    @PostMapping("startProcess")
    @RequiresPermissions({"outbound:save"})
    public ResultBean startOutboundProcess(@RequestBody OutboundBill outboundBill){
        System.out.println("出库申请详情：" + outboundBill);
        boolean rs = outboundProcessService.startOutboundProcess(outboundBill);
        return rs ? ResultBean.success() : ResultBean.error();
    }

    /**
     * 请假单流程推进
     */
    @PostMapping("complete")
    public ResultBean complete(@RequestBody OutboundCompleteData outboundCompleteData){
        System.out.println("出库流程推进信息：" + outboundCompleteData);
        outboundProcessService.complete(outboundCompleteData);
        return ResultBean.success();
    }
}
